package com.jeeplus.modules.guide.utils;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.Random;

public class DataUtils {
    public static boolean isNotNull(CharSequence cs) {
        if (cs != null  && !"null".equals(cs) && !"".equals(cs) && cs.length() != 0) {
            return true;
        } else {
            return false;
        }
    }

    public static boolean isToNull(CharSequence cs) {
        return !isNotNull(cs);
    }

    public static String getBeforeDate(){
        // 创建Random对象
        Random random = new Random();
        // 生成-1到-5的随机数
        int randomNumber = (random.nextInt(300) + 10) * -1;
        //核心代码
        Calendar myTime = Calendar.getInstance();
        myTime.add(Calendar.SECOND,randomNumber);
        Date beforeM = myTime.getTime();
        return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(beforeM);
    }
}
